import 'package:enterprise_v6_app/app/components/common/no_permissions_widget.dart';
import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/drawer_title.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/modules/application/intelligent_inspection_page/intelligent_inspection_controller.dart';

/// 智能巡检
class IntelligentInspectionPage extends StatelessWidget {
  IntelligentInspectionPage({super.key});

  final controller = Get.put(IntelligentInspectionController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          if (controller.titleList.isEmpty) {
            return const NoPermissionsWidget();
          }
          return Scaffold(
            key: controller.popRightScaffoldKey,

            appBar: CustomAppBar(
              titleText: controller.titleList[controller.selectIndex].expandTitle,
            ),
            body: Scaffold(
              key: controller.scaffoldKey,
              drawer: Drawer(
                width: 200.w,
                child: Container(
                  color: Colors.white,
                  child: Column(
                    children: [
                      DrawerTitle.titleDrawer('收起', AppImages.icon_pack_up).click(() {
                        controller.scaffoldKey.currentState?.closeDrawer();
                      }),
                      Column(
                        children: controller.titleList.map((e) {
                          return DrawerTitle.titleDrawer(e.title, e.icon,
                              isSelected:
                              controller.selectIndex == controller.titleList.indexOf(e))
                              .click(() {
                            controller.selectExpandMenu(controller.titleList.indexOf(e));
                          });
                        }).toList(),
                      ),
                    ],
                  ),
                ),
              ),
              body: Row(
                children: [
                  Container(
                    width: 60.w,
                    color: Colors.white,
                    alignment: Alignment.topCenter,
                    child: SingleChildScrollView(
                      child: Column(
                        children: [
                          DrawerTitle.title('展开', AppImages.icon_launch).click(() {
                            controller.scaffoldKey.currentState?.openDrawer();
                          }),
                          Column(
                            children: controller.titleList.map((e) {
                              return DrawerTitle.title(e.title, e.icon,
                                  isSelected:
                                  controller.selectIndex == controller.titleList.indexOf(e))
                                  .click(() {
                                controller.selectLeftMenu(controller.titleList.indexOf(e));
                              });
                            }).toList()
                          ),
                        ],
                      ),
                    ),
                  ),
                  Expanded(
                    child: controller.titleList[controller.selectIndex]
                        .pages[controller.titleList[controller.selectIndex].currentPageTitle],
                  ),
                ],
              ),
            ),
          );
        });
  }
}
